{extend name="admin/index"}

{block name="search"}

{/block}

{block name="main"}


<h2 class="sub-header">订单管理</h2>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>订单号</th>
            <th>影院</th>
            <th>电影</th>
            <th>放映时间</th>
            <th>大厅</th>
            <th>座位号</th>
            <th>用户</th>
            <th class='col-md-2'>手机号</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $order as $v}
        <tr>
            <td>{$v.ticket_number}</td>
            <td>{$v.name}</td>
            <td>{$v.filmname}</td>
            <td>{$v.date}{$v.playtime}</td>
            <td>{$v.hall_num}号厅</td>
            <td>{$v.seatnum}</td>
            <td>{$v.username}</td>
            <td>{$v.phone}</td>
            <td>
                <button class='btn btn-danger btn-sm del-btn' det-order="{$v.id}">删除</button>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <!--分页-->
    {$page}
    
    
</div>
</div>

{/block}
{block name="js"}
<script>
// 给当前选中的li添加标识
    $(".orders").addClass('active');
    
    $(function(){
        // 删除操作
        $('.del-btn').click(function(){
            var id = $(this).attr('det-order');
            if(confirm('确定要删除该用户吗?')){
                var obj = $(this).parents('tr');
                delajax(id, obj);
            }
        })
    })

// 删除函数
    function delajax(id, obj){
        $.ajax({
            type:'get',
            url: '/admin/orders/delete?id='+id,
            dataType:'json',
            success:function(data){
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info,'FBI WARNING: ');
                }
            },
            error:function(){
                alert('ajax执行失败');
            }
        })
    }
    
</script>
{/block}